package com.zw.cc.stock.common;


import com.zw.cc.stock.exception.BusinessException;
import com.zw.cc.stock.exception.NullObjectException;
import org.springframework.util.StringUtils;

public enum PolicyTypeEnum {

	HISTORY_HIGHER_PRICE_THREE("HHP3", "3天历史新高", 3),

	HISTORY_HIGHER_PRICE_FIVE("HHP5", "5天历史新高", 5),

	HISTORY_HIGHER_PRICE_TEN("HHP10", "10天历史新高", 10),

	HISTORY_LOWER_PRICE_THREE("HLP3", "3天历史新低", 3),

	HISTORY_LOWER_PRICE_FIVE("HLP5", "5天历史新低", 5),

	HISTORY_LOWER_PRICE_TEN("HLP10", "10天历史新低", 10),

	HIGH_STOCK_RATE("HSR", "高股息率", 10),

	DAWN_OCCURS("DNO", "曙光初现", 2),

	AH_PRICE_DIFF("AHD", "AH股比价", 5),

	SLEEVE_LINE("SLL", "挽袖线", 2),

	GREEN_SHADE_RED("GSR", "阴包阳", 2),

	RED_SHADE_GREEN("RSG", "阳包阴", 2),

	MOTHER_AND_SON("MAS", "母子线(身怀六甲)", 3),
	
	KDJ_SURPASS_BUYING("KSB", "KDJ买入", 120),
	
	KDJ_SURPASS_SELLING("KSS", "KDJ卖出", 120),

	KDJ_GOLD_CROSS("KGC", "KDJ金叉", 120),

	KDJ_DEATH_CROSS("KDC", "KDJ死叉", 120),

	KDJ_TOP_DEPART("KTD", "KDJ顶背离", 120),

	KDJ_BOTTOM_DEPART("KBD", "KDJ底背离", 120),

	MACD_GOLD_CROSS("MGC", "MACD金叉", 120),

	MACD_DEATH_CROSS("MDC", "MACD死叉", 120),
	
	MACD_TOP_DEPART("MAT", "MACD顶背离", 120),

	MACD_BOTTOM_DEPART("MAB", "MACD底背离", 120),
	
	MACD_SURPASS_BUYING("MBU", "MACD买入", 120),
	
	MACD_SURPASS_SELLING("MSU", "MACD卖出", 120),
	
	WR_GOLD_CROSS("WGC", "WR金叉", 120),
	
	WR_DEATH_CROSS("WDC", "WR死叉", 120),
	
	WR_SURPASS_BUYING("WSB", "WR买入", 120),
	
	WR_SURPASS_SELLING("WSS", "WR卖出", 120),
	
	WR_TOP_DEPART("WTD", "WR顶背离", 120),

	WR_BOTTOM_DEPART("WBD", "WR底背离", 120),
	
	MTM_GOLD_CROSS("MTC","MTM金叉",120),
	
	MTM_DEATH_CROSS("MCR","MTM死叉",120),
	
	MTM_SURPASS_BUYING("MSB","MTM买入",120),
	
	MTM_SURPASS_SELLING("MSS","MTM卖入",120),
	
	MTM_TOP_DEPART("MTD","MTM顶背离",120),
	
	MTM_BOTOM_DEPART("MBD","MTM底背离",120),
	
	BOLL_UPPER_LINE("BUL","BOLL突破上轨",120),
	
	BOLL_CENTER_LINE("BCL","BOLL突破中轨",120),
	
	BOLL_LOWER_LINE("BOL","BOLL突破下轨",120),
	
	AVG_LINE_GLUE("ALG","均线粘合",30),
	
	AVG_LINE_RANK("ALR","均线多头排列",30),

	TWO_RED_WRAP_GREEN("TRG", "两阳夹一阴", 3),

	TWO_GREEN_WRAP_RED("TGW", "两阴夹一阳", 3),

	THREE_RED("TRR", "红三兵（小三阳）", 3),

	SHODDY_GREEN("SDG", "假阴线", 1),

	SHODDY_RED("SDR", "假阳线", 1),

	BEARISH_ENGULFING("BRE", "穿头破脚", 2),

	IMMORTAL_GUIDING("ILG", "仙人指路", 6),

	RED_CROSS_THREE("RCT", "一阳三线", 30),

	HIBISCUS_RISE_WATER("HRW", "出水芙蓉", 20),

	LONG_LOWER_SHADOW("LLS", "长下影线", 1),

	GREEN_CROSS_LINE("GCL", "阴十字星", 1),

	RED_CROSS_LINE("RCL", "阳十字星", 1),

	GOLDEN_NEEDLE_DIP("GND", "金针探底", 5),

	RISING_CHANNEL("RSL", "上升通道", 20),

	BOX_BREAK("BXB", "箱体突破", 20),

	MULTI_CANNON("MCN", "多方炮", 120),

	PLATFORM_BREAK("PFB", "平台突破", 30),

	RSI_GOLD_CROSS("RGC", "RSI金叉", 120),

	RSI_DEATH_CROSS("RDC", "RSI死叉", 120),

	RSI_TOP_DEPART("RDD", "RSI顶背离", 120),

	RSI_BOTTOM_DEPART("RBD", "RSI底背离", 120),

	RSI_SURPASS_SELL("RSS", "RSI超卖", 120),

	RSI_SURPASS_BUY("RSB", "RSI超买", 120),

	CCI_SURPASS_BUY("CSB", "CCI超买", 120),

	CCI_SURPASS_SELL("CSS", "CCI超卖", 120),

	CCI_BOTTOM_DEPART("CBD", "CCI底背离", 120),

	CCI_TOP_DEPART("CTD", "CCI顶背离", 120),

	CCI_UPWARD("CUD", "CCI拐头向上", 120),

	CCI_BUY("CBY", "CCI买入", 100),

	CCI_SELL("CCS", "CCI卖出", 100),

	BIAS_GOLD_CROSS("BGC", "BIAS金叉", 120),

	BIAS_DEATH_CROSS("BDC", "BIAS死叉", 120),

	BIAS_SURPASS_BUY("BSB", "BIAS超买", 120),

	BIAS_SURPASS_SELL("BSS", "BIAS超卖", 120),

	BIAS_BOTTOM_DEPART("BBD", "BIAS底背离", 120),

	BIAS_TOP_DEPART("BTD", "BIAS顶背离", 120),
	
	MACD_SIXTY_GOLD_CROSS("MSC", "60分钟MACD金叉", 6),
	
	MACD_SIXTY_BOTTOM_DEPART("MMD", "60分钟MACD底背离", 6),
	
	MACD_THRETY_BOTTOM_DEPART("MTB", "30分钟MACD底背离", 30),
	
	RSI_SIXTY_SURPASS_SELL("RSE", "60分钟RSI超卖", 6),
	
	RSI_SIXTY_SURPASS_BUY("RBU", "60分钟RSI超买", 6),
	
	CCI_SIXTY_SURPASS_BUY("CCB", "60分钟CCI买入", 6),
	
	KDJ_SIXTY_GOLD_CROSS("KCR","60分钟KDJ金叉",6),

	HALFWAY_LIMIT_UP("HLP","盘中涨停",60),

	OPENING_LIMIT_UP("OLP","开盘涨停",60);




	private PolicyTypeEnum(String code, String desc, int interval) {
		this.code = code;
		this.desc = desc;
		this.interval = interval;
	}

	private String code;

	private String desc;

	/**
	 * 策略的跨度
	 */
	private int interval;

	public String getCode() {
		return code;
	}

	private void setCode(String code) {
		this.code = code;
	}

	public String getDesc() {
		return desc;
	}

	private void setDesc(String desc) {
		this.desc = desc;
	}

	public int getInterval() {
		return interval;
	}

	private void setInterval(int interval) {
		this.interval = interval;
	}

	public static PolicyTypeEnum transfer(String code) {
		if (!StringUtils.hasLength(code)) {
			throw new NullObjectException("policyTypeCode can not be null. ");
		}
		for (PolicyTypeEnum entity : values()) {
			if (code.equals(entity.getCode())) {
				return entity;
			}
		}
		throw new BusinessException(String.format("PolicyType[%s] is illegal. ", code));
	}
}
